<template>
  <div class="bigBox">
    <div class="header">
      <div>承诺书名称B</div>
      <div class="btnList">
        <el-button type="primary" class="close">关闭</el-button>
        <el-button type="primary" class="save">保存</el-button>
      </div>
    </div>
    <el-card class="box-card">
      <div class="cardForm">
        <el-select v-model="auditee" placeholder="请选择被审单位">
          <el-option v-for="item in companyList" :key="item.value" :label="item.label" :value="item.value"> </el-option>
        </el-select>
        <el-input v-model="auditName" placeholder="请输入审计实施方案名称">
          <template #suffix>
            <el-icon>
              <Search />
            </el-icon>
          </template>
        </el-input>
      </div>
    </el-card>
    <el-card class="table-card">
      <span class="tableTitle">相关审前调查通知书共计5个</span>
      <div class="tableBtn">
        <el-button type="primary">
          <el-icon class="el-icon--left"><Upload /></el-icon>上传文档
        </el-button>
        <el-button type="primary">
          <el-icon class="el-icon--left"><Plus /></el-icon>在线创建
        </el-button>
      </div>
      <div class="table-wrap">
        <basic-table
          :operateOptions="operateOptions"
          :columns="columns"
          :tableOptions="tableOptions"
          :tableEvents="tableEvents"
          :data="tableData"
          :pagination="pagination"
          @loadTableData="loadTableData"
        >
          <!-- <template #content="scope">
            <div class="distributed" v-if="scope.row.content === '1'">{{ scope }}已下发</div>
            <div class="unDistributed" v-else>已下发</div>
          </template> -->
          <!-- <template #opero="scope">
            <div class="distributed" v-if="scope.row.content === '1'">{{ scope }}已下发</div>
            <div class="unDistributed" v-else>已下发</div>
          </template> -->
        </basic-table>
      </div>
    </el-card>
  </div>
  <RecoverMoudle ref="recover" />
  <DelMoudle ref="delRef" />
  <EditModule ref="editRef" />
</template>

<script setup>
import { ref, reactive } from 'vue';
import RecoverMoudle from './component/recoverModule.vue';
import DelMoudle from './component/delModule.vue';
import EditModule from './component/editModule.vue';
// 表单
const auditee = ref('');
const companyList = reactive([
  {
    value: '选项1',
    label: '黄金糕',
  },
  {
    value: '选项2',
    label: '双皮奶',
  },
  {
    value: '选项3',
    label: '蚵仔煎',
  },
  {
    value: '选项4',
    label: '龙须面',
  },
  {
    value: '选项5',
    label: '北京烤鸭',
  },
]);
const auditName = ref('');
// 表格
const tableOptions = {
  emptyText: '暂无数据',
  border: false,
  stripe: true,
};
const pagination = {
  total: 100,
  currentPage: 1,
  pageSize: 10,
  pageSizes: [10, 20, 30, 40],
};

const loadTableData = (pagination) => {
  console.log('loadTableData', pagination);
};

const recover = ref(null);
const delRef = ref(null);
const editRef = ref(null);
const columns = reactive([
  {
    label: '承诺书名称',
    prop: 'title',
  },
  {
    label: '类型',
    slot: 'type',
  },
  {
    label: '编制人',
    prop: 'content',
    slot: 'content',
  },
  {
    label: '编制时间',
    prop: 'isRead',
    width: '170px',
  },
  {
    label: '是否下发',
    prop: 'isRead',
  },
  {
    label: '被审计单位',
    prop: 'conpany',
  },
  {
    type: 'option',
    minWidth: '86',
    items: [
      {
        text: '下载',
        icon: 'vc-icon vc-icon-table-check',
        click: () => {},
      },
      {
        text: '详情',
        icon: 'vc-icon vc-icon-table-check',
        click: () => {
          console.log('我点击了详情');
          editRef.value.editDialogVisable = true;
        },
      },
      {
        text: '编辑',
        icon: 'vc-icon vc-icon-table-check',
        click: () => {},
      },
      {
        text: '收回',
        type: 'option',
        click: () => {
          recover.value.recoverDialogVisable = true;
        },
      },
      {
        text: '删除',
        type: 'option',
        click: () => {
          delRef.value.delVisible = true;
        },
      },
    ],
  },
]);

const tableData = reactive([
  {
    title: '123',
    type: '123',
    content: '1',
    isRead: '123',
    createTime: '123',
  },
  {
    title: '123',
    type: '123',
    content: '0',
    isRead: '123',
    createTime: '123',
  },
]);
</script>

<style lang="scss" scoped>
.bigBox {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0px 16px;
  font-family: SourceHanSansSC-Regular, SourceHanSansSC;
  .table-card {
    margin-top: 16px;
    padding: 16px 24px;
    .distributed {
      width: 60px;
      height: 22px;
      background: rgba(46, 114, 239, 0.2);
      border-radius: 2px;
      font-size: 14px;
      line-height: 22px;
      text-align: center;
      font-weight: 400;
      color: #2e72ef;
    }
    .unDistributed {
      width: 60px;
      height: 22px;
      background: rgba(88, 115, 170, 0.2);
      border-radius: 2px;
      font-size: 14px;
      line-height: 22px;
      text-align: center;
      font-weight: 400;
      color: #5873aa;
    }
    .tableBtn {
      display: flex;
      align-items: center;
      margin-top: 19px;
      .el-button {
        width: 104px;
        height: 32px;
        background: #2e72ef;
        border-radius: 3px;
        .el-icon--left {
          font-size: 16px;
          margin-right: 5px;
          color: white !important;
        }
      }
      .el-button:nth-child(2) {
        margin-left: 16px;
      }
    }
    .tableTitle {
      font-size: 12px;
      font-weight: 400;
      color: #989da3;
    }
  }
  .header {
    height: 43px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    .btnList {
      // width: 106px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      :deep(.el-button) {
        width: 80px;
        height: 32px;
        background: #2e72ef;
        border-radius: 3px;
      }
    }
  }
  .box-card {
    height: 64px;
    .cardForm {
      height: 64px;
      margin: 0 24px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      .el-select {
        width: 240px;
        height: 32px;
      }
      .el-input {
        width: 370px;
        height: 32px;
        position: relative;
        .search {
          position: absolute;
          right: 10px;
          top: 8px;
        }
      }
    }
  }
}
</style>
